package org.test;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.text.SimpleDateFormat;

public class K {

	/**
	 * 
	 */
	public K() {
		super();
		// 获取当前类文件所在包的根目录
		System.out.println(System.getProperty("user.dir").replace("\\", "/"));
		// 获取当前类文件所在的目录
		System.out.println((getClass().getResource("").getPath()).replaceAll(
				"%20", " "));
	}

	public static void main(String args[]) {
		SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
		// 前面的lSysTime是秒数，先乘1000得到毫秒数，再转为java.util.Date类型
		long mileTime = System.currentTimeMillis();

		java.util.Date dt = new Date(mileTime);
		String sDateTime = sdf.format(dt); // 得到精确到秒的表示：08/31/2006 21:08:00
		System.out.println(sDateTime);
		// /////////////////////
		openDir();
		openDir2();
		//////////////////////////
		new K();
	}

	private static final String FILE_PATH = "D:\\娱乐\\琴音";

	/**
	 * How to open an dir like a man operation.
	 */
	private static void openDir() {
		try {
			String[] cmd = new String[5];
			cmd[0] = "cmd";
			cmd[1] = "/c";
			cmd[2] = "start";
			cmd[3] = " ";
			cmd[4] = FILE_PATH;
			Runtime.getRuntime().exec(cmd);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**
	 * Another way to open dir by code.
	 */
	private static void openDir2() {
		try {
			java.awt.Desktop.getDesktop().open(new File("D:\\娱乐\\琴音\\仙剑四音乐集"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
